package com.bwie.list.service.impl;

import com.alibaba.druid.sql.visitor.functions.Now;
import com.bwie.common.domain.Car;
import com.bwie.common.domain.Good;
import com.bwie.common.domain.Type;
import com.bwie.common.domain.request.CarVO;
import com.bwie.common.result.Result;
import com.bwie.list.mapper.CarMapper;
import com.bwie.list.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CarServiceImpl implements CarService {
    @Autowired
    private CarMapper carMapper;

    /**
     * 车辆列表
     */
    @Override
    public List<Car> findCarList(CarVO carVO) {
        List<Car> list = carMapper.findCarList(carVO);
        return list;
    }


    /**
     * 车辆类型列表
     */
    @Override
    public List<Type> findTypeList() {
        List<Type> list = carMapper.findTypeList();
        return list;
    }

    /**
     *登记
     */
    @Override
    public void add(Car car) {
        Integer add = carMapper.add(car);
    }

    @Override
    public void update(Car car) {
        Integer update = carMapper.update(car);
        if(update>0){

            Good good = new Good();
            Integer integer = carMapper.addGood(good);
            good.setGoodTime(new Date());
            good.setGoodNum(car.getCarNum());
            good.setGoodType(car.getTypeId());
            good.setGoodName(car.getCarName());
            good.setGoodPhone(car.getCarPhone());
            good.setGoodLei(car.getCarState());
        }
    }

    @Override
    public void update1(Car car) {
        carMapper.update(car);
    }

    @Override
    public List<Car> findListAll() {
        return carMapper.findListAll();
    }
}
